﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using SiGeSIB.Data.Management;

namespace SiGeSIB.Data.Finances
{
	public abstract class Movimentation
	{
		public Movimentation()
		{
			PaymentMethod = new PaymentMethod();
		}

		private CostCenter _CostCenter;
		private Contributor _Contributor;

		public decimal Amount { get; set; }
		public int Id { get; set; }
		public string Observation { get; set; }
		public bool IsFutureMovimentation
		{
			get
			{
				return MovimentationDate.CompareTo(DateTime.Today) > 0;
			}
		}
		public int CostCenterId { get; set; }
		public DateTime MovimentationDate { get; set; }
		public int ContributorId { get; set; }
		public abstract EMovimentationType Type { get; }
		public Contributor Contributor
		{
			get { return _Contributor; }
			set
			{
				_Contributor = value;
				if (value != null)
					ContributorId = value.Id;
			}
		}
		public CostCenter CostCenter
		{
			get { return _CostCenter; }
			set
			{
				_CostCenter = value;
				if (value != null)
					CostCenterId = value.Id;
			}
		}
		public PaymentMethod PaymentMethod { get; set; }

		#region Methods
		public static Movimentation Create(EMovimentationType type)
		{
			Movimentation mov = null;
			switch (type)
			{
				case EMovimentationType.Income:
					mov = new Income();
					break;
				case EMovimentationType.Outcome:
					mov = new Outcome();
					break;
				default:
					break;
			}
			return mov;
		}
		#endregion
	}
}
